package com.zimi.common.controller;

import com.zimi.common.service.CustomService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Api("custom")
@RestController
@RequestMapping("custom")
public class CustomApi {


    private final CustomService customService;

    @Autowired
    public CustomApi(CustomService customService) {
        this.customService = customService;
    }

    @GetMapping("cols")
    @ApiOperation("根据表名获取所有列和注释")
    public Map<String, String> getCols(@RequestParam("entityName") String entityName) {
        return customService.cols(entityName);
    }

    @GetMapping("table")
    @ApiOperation("获取数据库所有表及其注释")
    public Map<String, String> getTables() {
        return customService.tables();
    }

}
